package com.jiutong.meipengdai.http.present;

import android.content.Context;

import com.jiutong.meipengdai.entity.BaseRespond;
import com.jiutong.meipengdai.entity.CityListRespond;
import com.jiutong.meipengdai.entity.MapLoactionRespond;
import com.jiutong.meipengdai.http.model.interfaces.BaseBiz;
import com.jiutong.meipengdai.http.model.requests.GaodeMapRequest;
import com.jiutong.meipengdai.http.subscribers.ProgressSubscriber;
import com.jiutong.meipengdai.http.subscribers.SubscriberOnNextListener;

import java.util.HashMap;

/**
 * Created by suxi on 2017/5/31.
 */

public class GaodeMapPresent {

    private final Context mContext;
    private final BaseBiz mBaseBiz;
    private final GaodeMapRequest mapRequest;

    public GaodeMapPresent(Context context, BaseBiz baseBiz){
        this.mContext = context;
        this.mBaseBiz = baseBiz;
        mapRequest = new GaodeMapRequest();
    }

    public void loadMarker(){
        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<CityListRespond>() {
            @Override
            public void onNext(CityListRespond subjects) {
                mBaseBiz.onSuccess(subjects);
            }

            @Override
            public void onError(Throwable e) {
                mBaseBiz.onError(e);
            }
        };

        HashMap<String, Object> fieldsMap = new HashMap<>();
        fieldsMap.put("areaCode", "1988");
        fieldsMap.put("resultAreaType", "4");
        mapRequest.loadMarker(new ProgressSubscriber(onNextListener, mContext), fieldsMap);
    }


}
